const columnMixin = {
  data() {
    return {
      columnSHow: {}, //table列展示/隐藏-{userId:true,loginName:true,userName:true}
      columnAry: [] //设置展示列-下拉框，选中的值-['userId','loginName','userName']
    }
  },
  mounted() {
    // 默认设置列全部展示
    if (this.columnList) {
      this.setColumnSHow()
    }
  },
  methods: {
    /* 选择展示列后，触发 */
    setColumns(ary) {
      Object.keys(this.columnSHow).forEach((item, index) => {
        this.columnSHow[item] = ary.includes(item)
      })
    },
    /* 默认设置列，全部展示 */
    setColumnSHow() {
      let _this = this
      let ary = []
      this.columnList.forEach((item, index) => {
        _this.$set(_this.columnSHow, item.value, true)
        ary.push(item.value)
      })
      this.columnAry = ary
    }
  }
}
export { columnMixin }
